<?php
        include "include/top.php"
?>
<?php
//print_r( $_POST );
$name = $_POST['name'];
$password = $_POST['password'];
if ((!isset($name)) || (!isset($password))) 
{
//Visitor needs to enter a name and password
echo "name=$name";
echo "pwd=$password";
echo "<br />";
} else 
{
// connect to mysql
$mysql = mysqli_connect("localhost", "ospms", "ospms");
if(!$mysql) {
echo "Cannot connect to database.";
exit;
}
// select the appropriate database
$selected = mysqli_select_db($mysql, "OSPMS");
if(!$selected) {
echo "Cannot select database.";
header("Location: https://test2.transpolink.com/OSPMS/index.php");
exit;
}
// query the database to see if there is a record which matches
$query = "select count(*) from customer_info where
cust_id = '".$name."' and
cust_pwd = '".$password."'";
$result = mysqli_query($mysql, $query);
if(!$result) {
echo "Cannot run query.";
exit;
}
$row = mysqli_fetch_row($result);
$count = $row[0];
if ($count = 0) {
// name and password combination are not correct
echo "<h1>Please Leave!</h1>
<p>You are not authorized to use this resource.</p>";
exit;
}
// name and password combination are correct
//echo "<h2>CWC Network Status Display</h2>
//<p>Network Status for $name</p>";
//echo "<h2>CWC Network Status for $name</h2>";

$query = "select * from customer_info where
cust_id = '".$name."' and
cust_pwd = '".$password."'";
$result = mysqli_query($mysql, $query);
$row = mysqli_fetch_row($result);
$url_display = $row[2];
$port_num_display = $row[3];

//echo "url_and_port_num=<a href=\"http://$url_and_port_num\">$url_and_port_num</a><br />";
//printf("url_and_port_num=<a href=\"http://$url_and_port_num\">$url_and_port_num</a><br />");

//printf("<script>location.href='http://www.google.com'</script>");  // for testing only

//echo "<table border=1>";
//echo "<tl>";
//echo "<td>$url_display</td>";
//echo "<td>$port_num_display</td>";
$url_and_port_num = $url_display.":".$port_num_display;
//echo "</tl></table>";

//printf("url_and_port_num=<a href=\"$url_and_port_num\">$url_and_port_num</a><br />");
//header("Location $url_display");
//printf("<script>location.href='http://$url_and_port_num'</script>");
//echo '<iframe src="http://$url_and_port_num" style="width: 90%; width: 1200 px; height: 900px" \
//scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0"> \
//</iframe>';
//echo "<iframe src=\"http://$url_and_port_num\" style=\"width: 80%; width: 600 px; height: 400px\" \
echo "<iframe src=\"http://www.forensicswiki.org/wiki/Document_Metadata_Extraction\" style=\"width: 80%; width: 600 px; height: 400px\" \
scrolling=\"yes\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"1\" vspace=\"0\" hspace=\"0\"> \
</iframe>";
}
?>
<?php
        include "include/bottom.php"
?>
